//
//  MainCollectionViewCell.m
//  lsOA
//
//  Created by 蓝水软件 on 16/7/30.
//  Copyright © 2016年 苏州蓝水有限公司. All rights reserved.
//

#import "MainCollectionViewCell.h"

@implementation MainCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        CGSize imageSize ;
        if (IS_IPHONE_4) {
            imageSize = CGSizeMake(60, 60);
        }else if (IS_IPAD){
        
            imageSize = IPADCGSizeMake(60, 60);
        }
        
        else{
            imageSize = LRLCGSizeMake(60,60);
        }
        
        _image = [[UIImageView alloc]init];
        
        [self.contentView addSubview:_image];
        [_image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(imageSize);
            make.center.equalTo(self.contentView);
        }];
        self.contentView.backgroundColor = [UIColor clearColor];
        _label = [[UILabel alloc]init];
        if (IS_IPHONE_5 || IS_IPHONE_4) {
            _label.font = FONT(20);
        }else{
            _label.font = FONT(25);
        }
        
        _label.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_label];
        [_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_image.mas_bottom).offset(5);
            make.width.mas_equalTo(self.contentView);
        }];
        
        _num = [[UILabel alloc]init];
        _num.textColor = [UIColor colorWithRed:0.993 green:0.976 blue:1.000 alpha:1.000];
        _num.font = FONT(15);
        [self.contentView addSubview:_num];
        [_num mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_image);
            make.left.equalTo(_image.mas_right).offset(-10);
            make.size.mas_equalTo(CGSizeMake(45*FitSize, 18*FitSize));
        }];
        _num.layer.cornerRadius = 9*FitSize;
        _num.layer.masksToBounds = YES;
        _num.textAlignment = NSTextAlignmentCenter;
    }
    return self;
}

- (void)configWithImage:(UIImage *)image title:(NSString *)title unreadNum:(NSString *)num{
    _image.image = image;
    _label.text = title;
    _num.text = num;
    if ([[num substringWithRange:NSMakeRange(0, 2)] isEqualToString:@"0/"]) {
        _num.backgroundColor = [UIColor colorWithRed:0.400 green:0.800 blue:1.000 alpha:1.000];
    }else if (num.length == 0){
        _num.hidden = YES;
    }else {
        _num.backgroundColor = [UIColor colorWithRed:1.000 green:0.400 blue:0.400 alpha:1.000];
    }
}




@end
